#include "MQTTClient.h"
#include <string.h>
#include <unistd.h>

int main(int argc, char const *argv[])
{
	MQTTClient mqttClient("/mqtt/topic1", "/mqtt/topic2", 0);
	bool       ok = mqttClient.connect("192.168.2.109", 1883);
	if(!ok)
	{
		return -1;
	}

#if 0
	while(1)
	{
		const char *msg = "hell world";
		mqttClient.send(msg, strlen(msg));
		sleep(1);
	}
#endif

	char buf[1024] = {0};
	while(1)
	{
		int ret = mqttClient.recv(buf, sizeof(buf));
		if(ret < 0)
		{
			fprintf(stderr, "Fail to recv\n");
			return -1;
		}
		buf[ret] = '\0';
		printf("Recv %d bytes : %s \n", ret, buf);
	}

	return 0;
}
